################################################################################
# Copyright (C) 2014 Jeremy Brodt and Kevin Gillespie
# $Id: Makefile 36 2014-04-15 18:53:09Z brodtj1212@gmail.com $
################################################################################

# This is the name of the build output file
PROJECT=car

# Increase heap size
HEAP_SIZE=8192

# Set this variable to '1' to build for an emulator target
EMULATOR=0

# This is the path to the CMSIS root directory
CMSIS_ROOT=../../Libraries/CMSIS

# These are library directories
PERIPH_DRIVER_DIR=../../Libraries/MAX32550PeriphDriver
RTOS_DIR=../../Libraries/FreeRTOS
BSP_DIR=../../Libraries/BSP/MAX32550_KIT_V2P0

# Source files for this test (add path to VPATH below)
SRCS  = main.c
SRCS += libc_stubs.c

# Add libraries
LIBS  = ${PERIPH_DRIVER_DIR}/Build/MAX32550PeriphDriver.a
LIBS += ${RTOS_DIR}/Build/librtos.a

# Where to find source files for this test
VPATH=./src

# Where to find header files for this test
IPATH=./src
IPATH+=${PERIPH_DRIVER_DIR}/Include
IPATH+=${RTOS_DIR}
IPATH+=${RTOS_DIR}/Source/portable/GCC/ARM_CM3
IPATH+=${RTOS_DIR}/Source/include

# This is the include path for the RTOS configuration file
RTOS_CONFIG_DIR=$(shell pwd)/src

# Use this variables to specify and alternate tool path
#TOOL_DIR=/opt/gcc-arm-none-eabi-4_8-2013q4/bin
#EXT_LIB_DEFS += TOOL_DIR=${TOOL_DIR}

# Use these variables to add project specific tool options
#PROJ_CFLAGS+=--specs=nano.specs
#PROJ_LDFLAGS+=--specs=nano.specs

# Point this variable to a startup file to override the default file
#STARTUPFILE=start.S

# Point this variable to a linker file to override the default file
#LINKERFILE=$(CMSIS_ROOT)/Device/Maxim/MAX32550/Source/GCC/max32550_ram.ld

# Include the BSP
include $(BSP_DIR)/bsp.mk

# Include the rules for building for this target
include $(CMSIS_ROOT)/Device/Maxim/MAX32550/Source/GCC/max32550.mk

################################################################################
# Add project specific makefile targets from here

# Rule to build the Peripheral Driver Library
${PERIPH_DRIVER_DIR}/Build/MAX32550PeriphDriver.a:
	make -C ${PERIPH_DRIVER_DIR} lib ${EXT_LIB_DEFS}

${RTOS_DIR}/Build/librtos.a:
	make -C ${RTOS_DIR} lib RTOS_CONFIG_DIR=${RTOS_CONFIG_DIR} ${EXT_LIB_DEFS}

# The rule to clean out all the build products.
distclean: clean
	$(MAKE) -C ${PERIPH_DRIVER_DIR} clean
	$(MAKE) -C ${RTOS_DIR} clean

